home *** CD-ROM | disk | FTP | other *** search
- //----------------------------------------------------------------------------------------
- //----------------------------------------------------------------------------------------
- //
- // Filename : OpenGL.h
- // Description : Header file for OpenGL Class
- // Author : Marnich van Rensburg (2002)
- //
- //----------------------------------------------------------------------------------------
- //----------------------------------------------------------------------------------------
-
- #include <windows.h> // Windows Functions
- #include <stdio.h> // Standard Input\Output
- #include <stdarg.h> // Variable Argument Routines
- #include <time.h> // for time function
- #include <stdlib.h> // For srand and rand functions
-
- #include <gl\gl.h> // OpenGL32 Library
- #include <gl\glu.h> // GLu32 Library
- #include <gl\glaux.h> // GLaux Library
-
- #include "container.h"
- #include "tetramino.h"
- #include "gamestats.h"
- #include "timer.h"
- #include "top10.h"
-
- #ifndef OPENGL_H
- #define OPENGL_H
-
- //----------------------------------------------------------------------------------------
- // External Globals
- //----------------------------------------------------------------------------------------
-
- extern bool SoundActive;
- extern bool StarFieldActive;
-
-
- //----------------------------------------------------------------------------------------
- // Constants
- //----------------------------------------------------------------------------------------
-
- //Texture Filter Types
- #define NEAREST 0 // Create nearest Filtered Texture (Low quality / Fast rendering)
- #define LINEAR 1 // Create Linear Filtered Texture (Med quality / Med rendering)
- #define MIPMAP 2 // Create MipMapped Texture (High quality / Slow rendering)
-
- #define NUMBER_OF_TEXTURES 14
- #define NUMBER_OF_STARS 200
-
-
- struct Star
- {
- float x, y;
- };
-
- //----------------------------------------------------------------------------------------
- // Class Definition for OpenGL Class
- //----------------------------------------------------------------------------------------
-
- class OpenGL
- {
- //---------------------- Public -------------------------
-
- public:
- void DebugVal(float val);
-
-
- OpenGL(); //Constructor
- //Text
- void SetTextBase(int Base);
- GLvoid Print(GLint x, GLint y, const char *fmt, ...);
-
- //Init
- bool CreateGLWindow(char* title, int width, int height, int bits, bool fullscreenflag);
- bool InitGL();
- void SetFullScreen(bool fullscreen);
- bool GetFullScreen() const;
-
- //Render
- void RenderStartScreen(Top10& ref_HS);
-
- void RenderStart();
- void RenderGameTitle(float x, float y);
- void RenderContainer(Container& r_Container);
- void RenderNextPreview(Tetramino& ref_TetNext);
- void RenderRotationArrows(unsigned char UserAction);
- void RenderDropArrow(char Start, char End, bool DropState);
- void RenderGameStats(GameStats& Stats);
- void RenderGameOver(char Mode[4]);
- void RenderHighScoreScreen(char Name[25], char CursorPos, unsigned int Score);
- void RenderStarField();
- void RenderEnd();
-
- friend LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
- HDC GethDC() const;
- HWND GethWnd() const;
- GLvoid ReSizeGLScene(GLsizei width, GLsizei height);
-
- //Shutdown
- GLvoid KillGLWindow();
- void ErrorMsg(char *msg);
-
- //---------------------- Protected -------------------------
-
- protected:
-
- HDC hDC; // Private GDI Device Context
- HGLRC hRC; // Permanent Rendering Context
- HWND hWnd; // Holds Our Window Handle
- HINSTANCE hInstance; // Holds The Instance Of The Application
- bool FullScreen; // Fullscreen Flag Set To Fullscreen Mode By Default
-
-
- //---------------------- Private -------------------------
-
- private:
- void DrawFace(char Type); //Draws a textured quad based on type val passed
- void DrawGraphLine(float x, float y, float z, float Length);
-
- //Lights
- GLfloat LightAmbient[4];
- GLfloat LightDiffuse[4];
- GLfloat LightPosition[4];
-
- GLuint Texture[NUMBER_OF_TEXTURES]; // Storage Structure For Textures
- AUX_RGBImageRec* LoadBMP(char *Filename); // Loads A Bitmap Image
- bool LoadGLTextures(); // Load Bitmaps And Convert To Textures
-
- //Font
- GLuint fTexture[1]; //Stores the font texture
- GLuint fBase;
- int fWidth, fHeight, fSpacing, fStartPos, fxCount, fyCount, fdWidth, fdHeight;
- GLvoid LoadFont();
-
- Timer SFTmr;
- Star StarField[NUMBER_OF_STARS];
- void DrawStar(float x, float y, float z);
-
- };//Class OpenGL
-
- #endif;